package com.vm.dao.system;

import java.io.Serializable;

import java.util.List;
import java.util.Map;

import com.vm.dao.BaseDAOImpl;
import com.vm.entity.Agency;

import sun.management.resources.agent;


public class AgencyDAOImpl extends  BaseDAOImpl<Agency, String> implements IAgency{

	public AgencyDAOImpl(){
		setEntityClass(Agency.class);
	}

	public List<Agency> findByParentid(String parentid,String areaNo) {
		Object[] params = new Object[]{parentid};
		List<Agency> list = super.findByHql("FROM Agency WHERE suprOrgNo=? and arNo in "+"("+areaNo+")", params);
		return list;
	}
	
	public Agency findById (String id){
		return super.findById(id);
	}

	public void deleByParentid(String parentid) {
//		List<Agency> l = findByParentid(parentid);
//		for (Agency agency : l) {
//			super.delete(agency);
//		}
	}
	public List<Map<String, Object>> findAllAgency(String areaNo){
		String hql = "select orgNo as id,suprOrgNo as  pId,orgNm as name FROM Agency where arNo in "+"("+areaNo+")";
		return super.findBySqlALL(hql, null);
	}
	
	public Serializable save(Agency agency) {
		// agency.setOrgNo(this.produceId());
		return super.getHibernateTemplate().save(agency);
	}
	
	public String produceId(){
		return "11000000";
	}

}
